package com.pg.agent.engine.client.model.state;


import com.pg.agent.engine.client.model.agent.AIAgent;
import com.pg.agent.engine.client.model.sop.IntentRecognition;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class AIState implements Serializable {
    private static final long serialVersionUID = 9120606095133429217L;
    /**
     * sopId
     */
    private Long id;
    /**
     * 步骤名称
     */
    private String name;


    /**
     * 环境提示词
     */
    private String environmentPrompt;



    /**
     * 当前步骤的Agent列表
     */
    private List<AIAgent> aiAgentList;


    /**
     * 开始的Agent
     */
    private String beginAgent;


    /**
     * 是否开始
     */
    private boolean isBegin = true;

    /**
     * 汇总提示词
     */
    private String summaryPrompt;

    /**
     * 当前角色名称
     */
    private String currentRole;

    /**
     * 当前agent名称
     */
    private String currentAgent;

    /**
     * 意图识别
     */
    private IntentRecognition intentRecognition;


    /**
     * 索引
     */
    private int index = 0;

    /**
     * 聊天次数
     */
    private int chatNums = 0;

    /**
     * 标签集合
     */
    private List<String> labelList;

    private int answerIndex = 0;




    public List<String> listAgentName() {
        return aiAgentList.stream().map(AIAgent::getName).collect(Collectors.toList());
    }

    public AIAgent getAgent(String agentName) {
        return aiAgentList.stream().filter(aiAgent -> aiAgent.getName().equals(agentName)).findFirst().orElse(null);
    }
}
